#include<bits/stdc++.h>
using namespace std;

int a[5000005];

signed main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + n + 1);
	printf("%d", a[k + 1]);
	return 0;
}
